<template>
  <div id="app">
    <!-- 总体 -->
    <el-container>
      <!-- 头部 -->
      <el-header ref="header">
        <div class="title">
          <i class="iconfont icon-naozhong"></i>
          <span class="titletext">Zyqq个人博客</span>
        </div>
        <div>
          <el-dropdown @command="backLogin">
            <span class="el-dropdown-link">
              个人中心
              <i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="Editmsg">修改信息</el-dropdown-item>
              <el-dropdown-item command="Setup">系统设置</el-dropdown-item>
              <el-dropdown-item
                command="backtop"
                divided
              >退出</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </el-header>
      <!-- 身体 -->
      <el-container>
        <!-- 左边区域 -->
        <el-aside>
          <el-col :span="24">
            <el-menu
              background-color="#fff"
              text-color="#333"
              active-text-color="#7ec6e7"
              @select="openmenu"
            >
              <!-- 文章管理 -->
              <el-submenu index="1">
                <template slot="title">
                  <i class="el-icon-menu"></i><span>文章管理</span>
                </template>
                <el-menu-item index="/Sort">分类管理</el-menu-item>
                <el-menu-item index="/Tag">标签管理</el-menu-item>
                <el-menu-item index="/Article">文章管理</el-menu-item>
                <el-menu-item index="/Test">测试管理</el-menu-item>
              </el-submenu>
              <!-- 友情链接 -->
              <el-menu-item index="/Link">
                <i class="el-icon-menu"></i>
                <span slot="title">友情链接</span>
              </el-menu-item>
              <!-- 用户管理 -->
              <el-menu-item index="/User">
                <i class="el-icon-setting"></i>
                <span slot="title">用户管理</span>
              </el-menu-item>
            </el-menu>
          </el-col>
        </el-aside>
        <!-- 主体区域 -->
        <el-main :style="{ height: menuHeight + 'px' }">
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  data() {
    return {
      menuHeight: 0,
    };
  },
  methods: {
    openmenu(index) {
      this.$router.push(index);
    },
    backLogin(command) {
      switch (command) {
        case "Editmsg":
          break;
        case "Setup":
          break;
        case "backtop":
          localStorage.removeItem("token");
          this.$router.push("/Login");
          break;
      }
    },
  },
  mounted() {
    this.menuHeight = window.innerHeight - 80;
  },
};
</script>

<style scoped>
.el-container {
  height: 100%;
}
.el-header {
  width: 100%;
  background-color: #6bbee4df;
  height: 79px !important;
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.title {
  display: flex;
  align-items: center;
  margin: 25px 20px;
}
.icon-naozhong {
  font-size: 28px;
  color: #ffffff;
  margin-right: 10px;
}
.titletext {
  font-weight: 600;
  font-size: 22px;
}
.el-aside {
  width: 250px !important;
  overflow: hidden !important;
  border-right: 1px solid #ccc !important;
}
.el-dropdown-link {
  cursor: pointer;
  color: #ffffff;
  font-size: 18px;
}
.el-icon-arrow-down {
  font-size: 18px;
}
</style>
